/*
Copyright (C) Ariff Ehsan, Abdul Hadi Fikri

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*  Author : Abdul Hadi Fikri
 *  Date   : June 24, 2009
 */


#include <system.h>
#include <leds/leds.h>

/**
*CODE DESCRIPTION
*
*--Component in call section are function name which this module use from other module in order to complete its
*--tasks, event in turn is any event siganalled by the other module(s).  
*
*Component{
*	call{
*		LEDS -> LEDS_toggle(PINxn);
*		LEDS -> LEDS_set(value);
*		LEDS -> LEDS_on();
*	}
*}
*
**
*Data Field:
*/uint8_t led0;
  uint8_t led1;
  
  timer_t timer_pattern1;
  timer_t timer_pattern2;

/**
*Function Field:
*/void LED_PATTERN1(void);
  void LED_PATTERN2(void);

void APP_booted(){
	LEDS_init();
	
	TIMER_reg(&timer_pattern1,LED_PATTERN1);
	TIMER_reg(&timer_pattern2,LED_PATTERN2);
	
	TIMER_startPeriodic(&timer_pattern1,100);
	TIMER_startPeriodic(&timer_pattern2,300);
}

void LED_PATTERN1(void){
	led0 ^= 0x07;
	LEDS_set(led0|led1);
}

void LED_PATTERN2(void){
	led1 ^= 0x38;
	LEDS_set(led0|led1);
}